<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class UserApiEntrance
{
    public function handle(Request $request, Closure $next)
    {
        /*if (is_request_invalid()) {
            fail('非法请求');
        }*/

        $user = auth('api')->user();
        if ($user and $user->is_locked) {
            if (app()->environment('production')) {
                fail('对不起，您的账号因异常已被锁定，请联系客服');
            } else {
                fail('账号已注销');
            }
        }

        return $next($request);
    }
}
